package edu.tapestry.iddb.client.webService;

import iddb.AbstractCommand;
import iddb.AbstractResponse;
import iddb.IDDB;
import iddb.IDDBImplService;

import javax.xml.ws.BindingProvider;

public class IDDBProxy {

	int counter;
	IDDBImplService service;
	// IDDBService service;
	IDDB port;

	public IDDBProxy() {
		counter = 0;
		System.out.println("VYTVARIM...." + counter);
		service = new IDDBImplService();
		// service = new IDDBService();
		port = service.getPort(IDDB.class);
		// port = service.getIDDBPort();

		((BindingProvider) port).getRequestContext().put(
				BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);

	}

	

	public AbstractResponse execute(AbstractCommand cmd) {
		counter++;
		System.out.println(cmd.getClass() + "............" + counter);
		return port.exectute(cmd);
	}

	public int getCounter() {
		return counter;
	}

}
